(bug 19910) Preprocess headings of the form "===+\s+" in the same way as Parser:...
authorConrad Irwin <conrad@users.mediawiki.org>
Mon, 21 Jun 2010 20:33:07 +0000 (20:33 +0000)
committerConrad Irwin <conrad@users.mediawiki.org>
Mon, 21 Jun 2010 20:33:07 +0000 (20:33 +0000)
RELEASE-NOTES
includes/parser/Preprocessor_DOM.php
includes/parser/Preprocessor_Hash.php
maintenance/parserTests.txt

index b8de16d..79db694 100644 (file)
@@ -236,6 +236,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * (bug 24009) Include implicit groups in action=query&list=users&usprop=groups
 * (bug 24016) API: Handle parameters specified in simple string syntax 
   ( 'paramname' => 'defaultval' ) correctly when outputting help
+* (bug 19910) Headings of the form ===+\s+ are now displayed as valid headings
 
 === Languages updated in 1.17 ===
 
index 1dc1a17..60f975d 100644 (file)
@@ -467,7 +467,7 @@ class Preprocessor_DOM implements Preprocessor {
                                $count = $piece->count;
                                $equalsLength = strspn( $revText, '=', strlen( $text ) - $searchStart );
                                if ( $equalsLength > 0 ) {
-                                       if ( $i - $equalsLength == $piece->startPos ) {
+                                       if ( $searchStart - $equalsLength == $piece->startPos ) {
                                                // This is just a single string of equals signs on its own line
                                                // Replicate the doHeadings behaviour /={count}(.+)={count}/
                                                // First find out how many equals signs there really are (don't stop at 6)
index f029e9c..3fd06c1 100644 (file)
@@ -428,7 +428,7 @@ class Preprocessor_Hash implements Preprocessor {
                                $count = $piece->count;
                                $equalsLength = strspn( $revText, '=', strlen( $text ) - $searchStart );
                                if ( $equalsLength > 0 ) {
-                                       if ( $i - $equalsLength == $piece->startPos ) {
+                                       if ( $searchStart - $equalsLength == $piece->startPos ) {
                                                // This is just a single string of equals signs on its own line
                                                // Replicate the doHeadings behaviour /={count}(.+)={count}/
                                                // First find out how many equals signs there really are (don't stop at 6)
index 89a9587..49ceba2 100644 (file)
@@ -3902,6 +3902,23 @@ http://example.com [[Image:foobar.jpg]]
 </p>
 !!end
 
+!! test
+Short headings with trailing space should match behaviour of Parser::doHeadings (bug 19910)
+!! input
+=== 
+The line above must have a trailing space!
+=== <!--
+--> <!-- -->
+But just in case it doesn't...
+!! result
+<h1><span class="editsection">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: =">edit</a>]</span> <span class="mw-headline" id=".3D">=</span></h1>
+<p>The line above must have a trailing space!
+</p>
+<h1><span class="editsection">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;section=2" title="Edit section: =">edit</a>]</span> <span class="mw-headline" id=".3D_2">=</span></h1>
+<p>But just in case it doesn't...
+</p>
+!! end
+
 !! test
 BUG 1219 URL next to image (broken)
 !! input
@@ -5849,6 +5866,22 @@ section=1
 ==marked==
 !!end
 
+# Test behaviour of bug 19910
+!! test
+Sectiion with all-equals
+!! options
+section=2
+!! input
+=== 
+The line above must have a trailing space
+=== <!--
+--> <!-- -->
+But just in case it doesn't...
+!! result
+=== <!--
+--> <!-- -->
+But just in case it doesn't...
+!! end
 
 !! test
 Section replacement test (section 0)